﻿@Cofe ?= {}

uiUtils = 
  changeState : (state, possibleStates, uiElement) ->
    for s in possibleStates
      if (s isnt state)
        uiElement.removeClass(Cofe.States[s])
    uiElement.addClass(Cofe.States[state])

  showConfirmDialog : (confirmText,cancelText, onConfirm) ->
    $('#dialog-confirm').dialog({
      resizable: false,
      height:150,
      modal:true,
      buttons: {
        confirmText : () -> 
            onConfirm()
            $(this).dialog('close')
        cancelText : () -> 
            $(this).dialog('close')
      }
    })

  # Show message box
  showMessage : (content, caption) ->
    contentHtml = "<p style='padding:0px 5px'>" + content + "</p>"
    $('html').simpledialog2({ 
       mode: 'blank',
       headerText: caption,
       headerClose: true,
       blankContent : contentHtml    
    })        
  

  notify : (title, msg) ->
    #$.pnotify.defaults.styling = "jqueryui";
    $.pnotify({
      title: title
      text: msg
    });

  prompt : (title, def) ->
    return window.prompt(title, def)

Cofe.uiUtils = uiUtils